{extend name="template/base" /}
{block name="content"}
<div class="page-container">
    <form class="form form-horizontal" id="form" method="post" action="{:\\think\\Request::instance()->baseUrl()}">
        <input type="hidden" name="id" value="{$vo.id ?? ''}">
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>标题：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" placeholder="标题" name="title" value="{$vo.title ?? ''}"  datatype="*" nullmsg="请填写标题">
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        {if !$vo.content}
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>类型：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <div class="radio-box">
                    <input type="radio" name="type" id="type-0" value="0">
                    <label for="type-0">文章</label>
                </div>
                <div class="radio-box">
                    <input type="radio" name="type" id="type-1" value="1" datatype="*" nullmsg="请选择状态">
                    <label for="type-1">链接</label>
                </div>
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        {else /}
        <input type="hidden" name="type" value="{$vo.type}">
        {/if}
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3" id="content_title"><span class="c-red">*</span>内容：</label>
            <div class="formControls col-xs-6 col-sm-6">
                {if $vo.content && $vo.type == 1}
                    <input type="input" name="content" class="input-text" value="{$vo.content}" datatype="*" nullmsg="请输入链接地址">
                {else /}
                    <script id="content" name="content" type="text/plain" style="height:200px;width: 100%;">{:htmlspecialchars_decode($vo.content ?? '')}</script>
                {/if}
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>排序：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" placeholder="排序" name="sort" value="{$vo.sort ?? 1}"  datatype="*" nullmsg="请填写排序">
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>

        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <button type="submit" class="btn btn-primary radius">&nbsp;&nbsp;提交&nbsp;&nbsp;</button>
                <button type="button" class="btn btn-default radius ml-20" onClick="layer_close();">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
            </div>
        </div>
    </form>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__LIB__/Validform/5.3.2/Validform.min.js"></script>
<!--百度编辑器-->
<script>window.UEDITOR_HOME_URL = '__LIB__/ueditor/1.4.3/'</script>
<script type="text/javascript" charset="utf-8" src="__LIB__/ueditor/1.4.3/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__LIB__/ueditor/1.4.3/ueditor.all.min.js"></script>
<script type="text/javascript" charset="utf-8" src="__LIB__/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
<script>
    $(function () {

        {if !$vo.content || $v.type==0}
        var content = UE.getEditor('content', {
            serverUrl: '{:\\think\\Url::build("Ueditor/index")}'
        });
        function changeType(type){
            if (type==='0'){
                content = UE.getEditor('content', {
                    serverUrl: '{:\\think\\Url::build("Ueditor/index")}'
                });
            } else {
                console.log(content);
                content.destroy();
                $('#content').css('height','31px');
                $('#content').attr("name","content");
            }
        }

        $("[name='type'][value='{$vo.type ?? '0'}']").attr("checked", true);

        $("[name='type']").change(function () {
            var type_index = $("[name='type']:checked").val();
            changeType(type_index);
        });

        {/if}


        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        $("#form").Validform({
            tiptype: 2,
            ajaxPost: true,
            showAllError: true,
            callback: function (ret){
                ajax_progress(ret);
            }
        });
    })
</script>
{/block}
